package com.weihui.jxc.service.impl;

import java.util.List;

import com.weihui.jxc.dao.CustomerDao;
import com.weihui.jxc.dao.GoodsDao;
import com.weihui.jxc.model.Customer;
import com.weihui.jxc.model.Goods;
import com.weihui.jxc.model.GoodsInfo;
import com.weihui.jxc.service.GoodsService;

/**
 * 商品实现类
 * @author xiaowei
 *
 */
public class GoodsServiceImpl implements GoodsService{
	private GoodsDao goodsDao;

	/**
	 * 添加商品
	 */
	@Override
	public boolean saveGoods(Goods g) {
		goodsDao = new GoodsDao();
		return goodsDao.save(g);
	}

	/**
	 * 动态生成商品编号
	 */
	@Override
	public String getGoodsId() {
		goodsDao = new GoodsDao();
		return goodsDao.getId();
	}

	/**
	 * 查询商品信息
	 */
	@Override
	public List<Goods> findGoods(Goods good) {
		goodsDao = new GoodsDao();
		return goodsDao.query(good);
	}

	/**
	 * 查询商品信息
	 */
	@Override
	public List<GoodsInfo> findGoods(GoodsInfo good) {
		goodsDao = new GoodsDao();
		return goodsDao.query(good);
	}

	/**
	 * 修改商品信息
	 */
	@Override
	public boolean updateGoods(Goods g) {
		goodsDao = new GoodsDao();
		return goodsDao.update(g);
	}

	/**
	 * 删除商品
	 */
	@Override
	public boolean updateGoods(String id, Integer available) {
		goodsDao = new GoodsDao();
		return goodsDao.update(id, available);
	}
	
}
